using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class BK_Order
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Phone { get; set; }
        public string Note { get; set; }
        public DateTime CreatedDate { get; set; }
        public bool IsDeleted { get; set; }

        #region BK_OrderSelectAll
        public static List<BK_Order> BK_OrderSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_Order.BK_OrderSelectAll(strSearch,top,bottom,ConnectionString);
            List<BK_Order> BK_OrderList = new List<BK_Order>();
            while(dr.Read())
            {
                BK_Order myBK_Order = new BK_Order
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    Phone = !dr.IsDBNull(dr.GetOrdinal("Phone")) ? (string)dr["Phone"] : null,
                    Note = !dr.IsDBNull(dr.GetOrdinal("Note")) ? (string)dr["Note"] : null,
                    CreatedDate = !dr.IsDBNull(dr.GetOrdinal("CreatedDate")) ? (DateTime)dr["CreatedDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                BK_OrderList.Add(myBK_Order);
        }
        dr.Close();
        dr.Dispose();
        return BK_OrderList;
        }
        #endregion
        #region BK_OrderSelectRow
        public static BK_Order BK_OrderSelectRow(int ID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_Order.BK_OrderSelectRow(ID, ConnectionString);
            BK_Order bk_order = null;

            if(dr.Read())
            {
                bk_order= new BK_Order
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    Phone = !dr.IsDBNull(dr.GetOrdinal("Phone")) ? (string)dr["Phone"] : null,
                    Note = !dr.IsDBNull(dr.GetOrdinal("Note")) ? (string)dr["Note"] : null,
                    CreatedDate = !dr.IsDBNull(dr.GetOrdinal("CreatedDate")) ? (DateTime)dr["CreatedDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,

                };
            }
        dr.Close();
        dr.Dispose();
        return bk_order;
        }
        #endregion
        #region BK_OrderInsertRow
        public static void BK_OrderInsertRow(int ID, string Name, string Phone, string Note, DateTime CreatedDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_Order.BK_OrderInsertRow(ID, Name, Phone, Note, CreatedDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region BK_OrderUpdateRow
        public static void BK_OrderUpdateRow(int ID, string Name, string Phone, string Note, DateTime CreatedDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_Order.BK_OrderUpdateRow(ID, Name, Phone, Note, CreatedDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region BK_OrderDeleteRow
        public static void BK_OrderDeleteRow(int ID, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_Order.BK_OrderDeleteRow(ID,ConnectionString);
        }
        #endregion
    }
}
